<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品详情页</title>
    <link rel="stylesheet" href="../css/base.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        h1 {
            width: 1200px;
            height: 90px;
            margin: 0 auto;
            background-color: skyblue;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
        }

        h1>p {
            font-size: 20px;
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            right: 50px;
            display: none;

        }

        h1>p.back {
            display: block;
            color: red;
            text-decoration: none;
            position: absolute;

        }




        .product-container {
            width: 1200px;
            margin: 20px auto;
            display: flex;
            gap: 20px;
        }

        .product-image {
            width: 50%;
            background: #f5f5f5;
        }

        .product-image img {
            width: 100%;
            height: auto;
            display: block;
        }

        .product-info {
            width: 50%;
            background: pink;
            padding: 40px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            min-height: 400px;
        }

        .product-title {
            font-size: 22px;
            margin-bottom: 56px;
            color: #333;
            line-height: 1.2;
        }

        .price-section {
            margin: 30px 0;
        }

        .price-label {
            color: red;
            font-size: 30px;
            line-height: 1.2;

        }

        .original-price {
            font-size: 30px;
            text-decoration: line-through;
            color: #666;
        }

        .discount {
            color: red;
            font-size: 30px;
            margin: 30px 0;
        }

        .discount span {
            color: yellowgreen;
            font-size: 30px;
        }

        .current-price {
            color: red;
            font-size: 30px;
            margin-top: 30px;
        }

        .current-price-value {
            font-size: 30px;
            color: red;
        }

        .product-introduce{
            width: 1200px;
            justify-content: center;
            align-items: center;
            position: relative;
            display: flex;
            margin: 0 auto;

        }
    </style>
</head>
<body>
    <h1>
        <div class="title"></div>商品详情页</div>
        <p class="back"><a href="/list.html">回到列表页</a></p>
    </h1>

    <div class="product-container">
        <div class="product-image">
            
            <div id="productImage"></div>
        </div>
        <div class="product-info" id="productDetail">
            <!-- 商品详情将通过JavaScript动态生成 -->
        </div>
    </div>

    <div class="product-introduce" id="productIntroduce"></div>

    <script src="../js/goods.js"></script>
    <script>
        const urlParams = new URLSearchParams(window.location.search);
        const goodsId = urlParams.get('id');
        const product = list.find(item => item.goods_id == goodsId);

        if (product) {
            // 渲染商品图片
            document.getElementById('productImage').innerHTML = `
                <img src="${product.img_big_logo}" alt="${product.title}">
            `;

            // 渲染商品信息
            document.getElementById('productDetail').innerHTML = `
                <h2 class="product-title">${product.title}</h2>
                
                <div class="price-section">
                    <span class="price-label">原价: ￥</span>
                    <span class="original-price">${product.price}</span>
                </div>

                <div class="discount">
                    折扣: <span>${product.sale_type}</span>
                </div>

                <div class="current-price">
                    现价: ￥<span class="current-price-value">${product.current_price}</span>
                </div>
            `;

            document.getElementById('productIntroduce').innerHTML = `
                <div class="price-introduce">${product.goods_introduce}</div>
            
            `;
        }
    </script>
</body>
</html>